import java.util.Scanner;

public class demo01 {
    //递增三元组
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        long[] arr1=new long[n];
        for(int i=0;i<n;i++){
            arr1[i]=sc.nextInt();
        }
        long[] arr2=new long[n];
        for(int i=0;i<n;i++){
            arr2[i]=sc.nextInt();
        }
        long[] arr3=new long[n];
        for(int i=0;i<n;i++){
            arr3[i]=sc.nextInt();
        }
        int count=0;
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                for(int k=0;k<n;k++){
                    if(arr1[i]<arr2[j]&&arr2[j]<arr3[k]){
                        count++;
                    }
                }
            }
        }
        System.out.println(count);
        sc.close();
    }
}
